#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    File Name:      test_easyquotation
    Author:         'daze'
    date:           2018/12/19
    description:    实时获取行情信息
"""
import easyquotation

# 选择新浪行情
# quotation = easyquotation.use('sina')  # 新浪 ['sina'] 腾讯 ['tencent', 'qq']
# print('sina quotation=' + str(quotation)) # object

# 获取所有股票行情
# all_quotation = quotation.market_snapshot(prefix=True)  # prefix 参数指定返回的行情字典中的股票代码 key 是否带 sz/sh 前缀
# print('all_quotation=' + str(all_quotation)) # json

# 获取单只股票
# single_quotation = quotation.real('162411')  # 支持直接指定前缀，如 'sh000001'
# print('single_quotation=' + str(single_quotation)) # json

# 多只股票
# multi_quotation = quotation.stocks(['000001', '162411'])
# print('multi_quotation=' + str(multi_quotation))  # json

# 同时获取指数和行情
# index_quotation = quotation.stocks(['sh000001', 'sz000001'], prefix=True)
# print('index_quotation=' + str(index_quotation)) # json

# 更新股票代码
# update_stock_result = easyquotation.update_stock_codes()
# print('update_stock_result=' + str(update_stock_result))

# 选择 jsl 行情(jsl 是集思录）
# jsl_quotation = easyquotation.use('jsl')  # ['jsl']
# print('jsl_quotation=' + str(jsl_quotation))  # easyquotation.jsl.Jsl object
# 获取分级基金信息
# print('jsl_quotation.funda()=' + str(jsl_quotation.funda()))  # 参数可选择利率、折价率、交易量、有无下折、是否永续来过滤
# print('jsl_quotation.fundb()=' + str(jsl_quotation.fundb()))  # 参数如上
# 分级基金套利接口
# jsl_username = '不吃鸟的虫'
# jsl_password = 'qwertzxcv2'
# jsl_quotation.fundarb(jsl_username, jsl_password, avolume=100, bvolume=100, ptype='price') # json 解析异常

# 指数 ETF 查询接口
# etf_query_result = jsl_quotation.etfindex(index_id="", min_volume=0, max_discount=None, min_discount=None)
# print('etf_query_result=' + str(etf_query_result)) # json

# 腾讯分时图
# quotation = easyquotation.use("timekline")
# data = quotation.real(['603828'], prefix=True)
# print('腾讯分时图=' + str(data))

# 港股日k线图
# quotation = easyquotation.use("daykline")
# data = quotation.real(['00001', '00700'])
# print('港股日k线图=' + str(data))

# 腾讯港股时时行情
quotation = easyquotation.use("hkquote")
data = quotation.real(['00001', '00700'])
print('腾讯港股时时行情=' + str(data))
